package com.example.javawebdemo.command;

import java.util.HashMap;
import java.util.Map;

// CommandFactory.java
public class CommandFactory {
    private static Map<String, ProductCommand> commandMap = new HashMap<>();

    static {
        commandMap.put("edit", new EditCommand());
        commandMap.put("delete", new DeleteCommand());
        commandMap.put("list", new ListCommand());
    }

    public static ProductCommand getCommand(String action) {
        return commandMap.getOrDefault(action, new ListCommand());
    }
}

